<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Urun extends MY_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */

    public function __construct()
    {
        parent::__construct();
            // Your own constructor code
      $this->load->library('MyCategories'); 
                
    } 
	public function index()
	{
        $this->load->view('layouts/dashboard');
	}
    public function show_product($product_name,$product_id)
    {
        
        $data['product'] = $this->product_model->get_product($product_id)->row(0);
        $data['category_name'] = $this->config_model->get_category_name($data['product']->category_id)->row(0)->name;
        $data['subcategory_name'] = $this->config_model->get_subcategory_name($data['product']->subcategory_id)->row(0)->name;


        $data['subview'] = 'urunler/product_detail';
        $this->load->view('layouts/default_detail',$data);  
    }
    public function hemen_al($product_name,$product_id,$seller_id = NULL)
    {
        $data['product'] = $this->product_model->get_product($product_id)->row(0);
        

        $data['category_name'] = $this->config_model->get_category_name($data['product']->category_id)->row(0)->name;
        $data['subcategory_name'] = $this->config_model->get_subcategory_name($data['product']->subcategory_id)->row(0)->name;

        $data['seller_id'] = $seller_id;
        $data['seller_info'] = $this->db->where('seller_id',$seller_id)->get('seller')->row(0);
        $data['subview'] = 'urunler/view_hemen_al';
        $this->load->view('layouts/default1',$data);
    }

    public function hizli_sat($product_name,$product_id,$seller_id = NULL)
    {
        $data['product'] = $this->product_model->get_product($product_id)->row(0);
        

        $data['category_name'] = $this->config_model->get_category_name($data['product']->category_id)->row(0)->name;
        $data['subcategory_name'] = $this->config_model->get_subcategory_name($data['product']->subcategory_id)->row(0)->name;

        $data['seller_id'] = $seller_id;
        $data['seller_info'] = $this->db->where('seller_id',$seller_id)->get('seller')->row(0);
        $data['subview'] = 'urunler/view_hizli_sat';
        $this->load->view('layouts/default1',$data);
    }
    public function hizli_al($seller_id = NULL)
    {
        $this->db->select('*');
        $this->db->from('products');
        $this->db->join('seller','seller.product_id = products.product_id');
        // limit eklenicek
        $this->db->where(array('mod' => 1, 'seller_id' => $seller_id));
        $data['product'] = $this->db->get()->row(0);
        
        //$data['product'] = $this->product_model->get_product($product_id)->row(0);
        
     
        $data['category_name'] = $this->config_model->get_category_name($data['product']->category_id)->row(0)->name;
        $data['subcategory_name'] = $this->config_model->get_subcategory_name($data['product']->subcategory_id)->row(0)->name;

        $data['seller_id'] = $seller_id;
        $data['seller_info'] = $this->db->where('seller_id',$seller_id)->get('seller')->row(0);
        $data['subview'] = 'hizli_al_sat/view_hizlial_detail';
        $this->load->view('layouts/default1',$data);
    } 
    
    public function hizli_talep_et($product_name,$product_id,$seller_id = NULL)
    {
        $data['product'] = $this->product_model->get_product($product_id)->row(0);
        $sql = "select * from seller,products where products.product_id = ? and seller.product_id = products.product_id order by seller.user_price";
        if($this->db->query($sql,$product_id)->num_rows()> 0)
        {
            // varsa productları cek bi sayfada bastır
            // en altada yinede devm etmek istiomusnuz
            $data['products'] =$this->db->query($sql,$product_id)->result();
            $data['subview'] = 'talepler_list';
            $this->load->view('layouts/default3',$data);
        }
        else
        {
                
            $data['category_name'] = $this->config_model->get_category_name($data['product']->category_id)->row(0)->name;
            $data['subcategory_name'] = $this->config_model->get_subcategory_name($data['product']->subcategory_id)->row(0)->name;
    
            $data['seller_id'] = $seller_id;
            $data['seller_info'] = $this->db->where('seller_id',$seller_id)->get('seller')->row(0);
            $data['subview'] = 'urunler/view_hizli_talep_et';
            $this->load->view('layouts/default1',$data);
            
        }


    }
    public function hizli_talep_et_devam($product_name,$product_id,$adet = NULL,$fiyat = NULL)
    {
        $data['product'] = $this->product_model->get_product($product_id)->row(0);

 
                
            $data['category_name'] = $this->config_model->get_category_name($data['product']->category_id)->row(0)->name;
            $data['subcategory_name'] = $this->config_model->get_subcategory_name($data['product']->subcategory_id)->row(0)->name;
    
            //$data['seller_id'] = $seller_id;
            $data['adet'] = $adet;
            $data['fiyat'] = $fiyat;
         //   $data['seller_info'] = $this->db->where('seller_id',$seller_id)->get('seller')->row(0);
            $data['subview'] = 'urunler/view_hizli_talep_et';
            $this->load->view('layouts/default1',$data);
            
        


    }         
    

         
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */